package com.example.c201901090104;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;

import android.app.FragmentTransaction;
import android.os.Build;
import android.os.Bundle;
import android.view.View;

import com.jaeger.library.StatusBarUtil;

public class MainActivity extends AppCompatActivity {
    public static MainActivity instance=null;
    ShouyeFragment shouye=new ShouyeFragment();
    ShipinFragment quan=new ShipinFragment();
    RebangFragment xiaoxi=new RebangFragment();
    WoFragment wo=new WoFragment();
    @RequiresApi(api = Build.VERSION_CODES.N)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        instance=this;
        StatusBarUtil.setColor(this,getColor(R.color.cengjinshi),0);
        View view1 =findViewById(R.id.constraintLayout);
        View view2=findViewById(R.id.constraintLayout2);
        View view3=findViewById(R.id.constraintLayout3);
        View view4=findViewById(R.id.constraintLayout4);
        view1.setSelected(false);
        view2.setSelected(true);
        view3.setSelected(false);
        view4.setSelected(false);
        getSupportFragmentManager().beginTransaction().replace(R.id.mycon,quan).commit();
        view1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                view1.setSelected(true);
                view2.setSelected(false);
                view3.setSelected(false);
                view4.setSelected(false);
                getSupportFragmentManager().beginTransaction().replace(R.id.mycon,shouye).commit();
            }
        });

        view2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                view1.setSelected(false);
                view2.setSelected(true);
                view3.setSelected(false);
                view4.setSelected(false);
                getSupportFragmentManager().beginTransaction().replace(R.id.mycon,quan).commit();
            }
        });

        view3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                view1.setSelected(false);
                view2.setSelected(false);
                view3.setSelected(true);
                view4.setSelected(false);
                getSupportFragmentManager().beginTransaction().replace(R.id.mycon,xiaoxi).commit();
            }
        });

        view4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                view1.setSelected(false);
                view2.setSelected(false);
                view3.setSelected(false);
                view4.setSelected(true);
                getSupportFragmentManager().beginTransaction().replace(R.id.mycon,wo).commit();
            }
        });
    }
}